<template lang="html">
    <div class="message">
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-message"></i>&nbsp;交易保障金和藏品审核费用</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div style="height:20px;"></div>
            <el-form label-width="150px" class="demo-ruleForm">
                <el-form-item label="交易保证金：">
                    <el-input type="text" v-model="margin" :disabled="true" style="width:200px;"></el-input>
                </el-form-item>
                <el-form-item label="设置交易保证金">
                    <el-input type="text" v-model="marginAdd" placeholder="请输入您要设置的保证金" style="width:200px;"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="submitMargin()">保存</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div style="height:20px;"></div>
        <div class="container">
            <div style="height:20px;"></div>
            <el-form label-width="150px" class="demo-ruleForm">
                <el-form-item label="藏品审核费用：">
                    <el-input type="text" v-model="audit" :disabled="true" style="width:200px;"></el-input>
                </el-form-item>
                <el-form-item label="设置藏品审核费用：" >
                    <el-input v-model="auditAdd" placeholder="请输入您要设置的藏品审核金额" style="width:200px;"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="submitAudit()">保存</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
</template>

<script>
import {getMargin,getAudit,postBondFee,postCheckFee} from '@/api/configuration/list'
    export default {
        name: "configcharge",
        data() {
            return {
                margin:'',//保证金
                marginAdd:'',//设置的保证金
                audit:'',//审核费用，
                auditAdd:'',//设置的审核费用
            }
        },
        created(){
            //获取保证金
            this.getMargin();
            //获取审核费用
            this.getAudit();
        },
        mounted() {
            
        },
        methods: {
            //获取保证金
            getMargin(){
                getMargin().then(res => {
                    this.margin = res.data;
                    this.marginAdd = this.margin;
                })
            },
            //提交，保证金
            submitMargin(){
                if(this.marginAdd == ''){
                    this.$message({
                        message: '请输入保证金价格！',
                        type: 'warning'
                    });
                    return false;
                }
                //设置
                // console.log(this.marginAdd);
                postBondFee(this.marginAdd).then(res => {
                    // console.log(res);
                    if(res.code == 200){
                        this.$message({
                            message: '保存成功！',
                            type: 'success'
                        });
                        this.getMargin();//重新加载
                    }else {
                        this.$message.error('保存失败！');
                    }
                })
            },
            //获取保证金
            getAudit(){
                getAudit().then(res => {
                    this.audit = res.data;
                    this.auditAdd = this.audit;
                })
            },
            //提交，审核费用
            submitAudit(){
                if(this.auditAdd == ''){
                    this.$message({
                        message: '请输入藏品审核价格！',
                        type: 'warning'
                    });
                    return false;
                }
                //设置
                postCheckFee(this.auditAdd).then(res => {
                    if(res.code == 200){
                        this.$message({
                            message: '保存成功！',
                            type: 'success'
                        });
                        this.getAudit();//重新加载
                    }else {
                        this.$message.error('保存失败！');
                    }
                })
            },
        }
    }
</script>

<style lang="css" scoped>
.del {
    color: #f00;
}
</style>
